<template>
  <div>
    <table>
      <tr>
        <td>id</td>
        <td>标题</td>
        <td>分类</td>
        <td>内容</td>
        <td>图片</td>
        <td>收费</td>
        <td>章节</td>
      </tr>
      <tr v-for="i in courses">
        <td>{{ i.id }}</td>
        <td>{{ i.title }}</td>
        <td>{{ i.caname }}</td>
        <td>{{ i.descrip }}</td>
        <td><img :src="i.pic" alt="" width="100px"></td>
        <td v-if="i.status==1">收费</td>
        <td v-else>免费</td>
        <td>
          <router-link :to="{path:'/show_jie',query:{'id':i.id}}">点击查看</router-link>
        </td>
      </tr>
    </table>
    <pages :total="total" @cpage="getpage"/>
  </div>
</template>

<script>
import pages from "../cate/pages";

export default {
  name: "show_courses",
  components: {
    'pages': pages
  },
  data() {
    return {
      courses: [],
      total: 0,
      page: 1
    }
  },
  methods: {
    get_courses() {
      this.$axios.get('/courses/courses?cpage=' + this.page)
        .then(res => {
          if (res.data.code == 200) {
            this.courses = res.data.list
            this.total = res.data.total
          }
        })

    },
    getpage(p) {
      this.page = p
      this.get_courses()
    }
  },
  mounted() {
    this.get_courses()
  }
}
</script>

<style scoped>

</style>
